import {
	createRouter,
	createWebHistory
} from 'vue-router'

import Layout from '@/layout/index.vue'

const router = createRouter({

	// 工作模式
	history: createWebHistory(),

	routes: [

		{
			path: '/',
			component: Layout,
			redirect: '/home',
			children: [

				// 首页
				{
					path: '/home',
					component: () => import('@/views/home/home.vue'),
					meta: {
						title: '首页',
					}
				},
			]
		},

		// 登录
		{
			path: '/login',
			component: () => import('@/views/login/login.vue'),
			meta: {
				title: '登录',
			}
		},

		// 404 路由，放在最后
		{
			path: "/:pathMatch(.*)",
			name: "404",
			component: () => import("@/views/404/index.vue"),
		},
	]
})

export default router